import sys
import os
import tkinter as tk
from tkinter import filedialog

def open_folder_dialog():
    root = tk.Tk()
    root.withdraw()
    folder_path = filedialog.askdirectory()
    return folder_path


def select_single_file(initial_dir="/"):
    root = tk.Tk()
    root.withdraw()
    file_path = filedialog.askopenfilename(initialdir=initial_dir, title="选择单个文件", filetypes=(("文件类型", "*.*"), ("All files", "*.*")))
    
    return file_path

if __name__ == "__main__":
    initial_dir = sys.argv[1] if len(sys.argv) > 1 else "/"
    print(select_single_file(initial_dir))

# 调用函数来打开文件夹选择窗口
# selected_folder = select_single_file()
# print("选择的文件夹路径为：", selected_folder)